<template>
  <div id="app">
    <img :src="code" alt />
    <div id="nav">
      <router-link to="/">Home</router-link>|
      <router-link to="/about/1">About</router-link>
    </div>
    <login-form></login-form>
    <router-view />
  </div>
</template>
<script>
import LoginForm from "@/components/LoginForm";
import axios from "axios";
export default {
  components: {
    LoginForm
  },
  data() {
    return {
      code: ""
    };
  },
  created() {
    axios
      .get("http://192.168.31.42:9123/api/app/captcha/index", {
        responseType: "arraybuffer"
      })
      .then(res => {
        this.code =
          "data:image/png;base64," +
          btoa(
            new Uint8Array(res.data).reduce(
              (data, byte) => data + String.fromCharCode(byte),
              ""
            )
          );
        console.log(res);
      });
  }
};
</script>
<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
